@page
@namespace MultiAgentsServer.Pages
@model InviteManagerModel
@{
    ViewData["Title"] = "Manage";
}

<div style="display: flex; height: 100vh;">
    <nav style="width: 200px; background: #f8f9fa; padding: 10px; height: 100vh; position: fixed; left: 0; top: 56px; z-index: 1000;">
        <ul style="padding: 0; list-style: none;">
            <li><a asp-page="UserPermissionManagement" style="cursor: pointer;">User Authority</a></li>
            <li><a asp-page="InviteManager" style="cursor: pointer;">Invite Code</a></li>
            <li><a asp-page="DefaultModelsManagement" style="cursor: pointer;">Model Configuration</a></li>
        </ul>
    </nav>
    <div style="margin-left: 200px; padding: 20px; flex-grow: 1;">
        <h4>invite code: @Model.InviteCode</h4>
        <form method="post">
            <button type="submit" formaction="?handler=RefreshInviteCode">refresh</button>
        </form>
        <button onclick="copyInviteCode()">copy</button>
    </div>
</div>

<script>
    function copyInviteCode() {
        navigator.clipboard.writeText("@Model.InviteCode").then(function () {
            alert('邀请码已复制!');
        }, function (err) {
            alert('复制失败: ', err);
        });
    }
</script>